package logic

import (
	"context"
	"user_srv/usersrvclient"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type ValiDateLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewValiDateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ValiDateLogic {
	return &ValiDateLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *ValiDateLogic) ValiDate(req *types.ValiDateRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	date, err := l.svcCtx.UserSrv.ValiDate(l.ctx, &usersrvclient.ValiDateRequest{
		UserId:   req.UserId,
		InCard:   req.IdCard,
		RealName: req.RealName,
	})
	if err != nil {
		return &types.Response{
			Code:    500,
			Message: err.Error(),
			Date:    nil,
		}, nil
	}
	return &types.Response{
		Code:    200,
		Message: "账号实名成功",
		Date:    date,
	}, nil
}
